package aer.NumerosCubinfinitos;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;

public class NumerosCubinfinitos {
	private static PrintWriter out = new PrintWriter(System.out);
	private static ArrayList<Integer> c = new ArrayList<Integer>();
	private static int posI, numero, original, acc, n;
	private static boolean sol, b = true;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (b) {
			c.clear();
			original = Integer.parseInt(br.readLine());
			if (original <= 0) {
				b = false;
			} else {
				out.print(original);
				numero = original;
				original = -1;
				programa();
			}
		}

		out.flush();
	}

	private static void programa() {
		if (numero == 1) {
			 out.print(" -> cubifinito.\n");
		} else if (comprobarAnteriores()) {
			out.print(" -> no cubifinito.\n");
		}

		else {
			if (original < 0) {
				original = numero;
			}
			c.add(numero);
			acc = 0;

			while (numero > 0) {
				posI = numero % 10;
				numero /= 10;
				posI *= posI * posI;
				acc += posI;
			}

			numero = acc;

			out.print(" - " + numero);
			programa();

		} // end else

	}

	private static boolean comprobarAnteriores() {
		n = numero;
		sol = false;
		for (int i : c) {
			if (n == i) {
				sol = true;
				break;
			}
		}

		return sol;
	}
}